package cn.yangliu.nacos.management.entity.sys;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import cn.yangliu.nacos.comm.audit.AbstractEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2020 -01-01
 */
@Entity
@Table(name = "cm_role")
@Data
public class Role extends AbstractEntity {

    /**
     * current class instance's member.
     * The Rolename.
     */
    private String rolename;

    /**
     * current class instance's member.
     * The Authorities.
     */
    @ApiModelProperty(value = "角色权限")
    @ManyToMany(cascade = CascadeType.REFRESH, targetEntity = Authority.class)
    @JoinTable(name = "cm_role_authority",
            joinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"),
            inverseJoinColumns = @JoinColumn(name = "authority_id", referencedColumnName = "id"))
    private List<Authority> authorities = new ArrayList<>();
}
